from core.item import Item
from core.action import Action
from core.support import get_game
from core.support import set_cutscene

class Soda(Item):
    def __init__(self):
        Item.__init__(self, "soda")    # do basic initialization for every item
        
        # build list of actions
        self.add_action(QuenchThirst)
        self.add_action(BlowUpDoor)
    
    def get_description(self):
            return "a can of soda"
        
    def get_image(self):
        return 'images/items/soda.jpg'

# define actions for this item

class QuenchThirst(Action):
    def __init__(self):
        Action.__init__(self, "quench_thirst")    # do basic initialization for every action
        self.isThirstQuenched = False
    
    # this method gets called when action executed.  can be overridden in subclass
    def do_action(self,game,room,request):
        self.isThirstQuenched = True
        set_cutscene("MacGyver feels refreshed.")
        return
    
    # should this action be available to player?
    def is_enabled(self):
        return not self.isThirstQuenched
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Quench Thirst"
    
    # if omitted in your action we return "post"
    def get_method(self):
        return "get"
    
class BlowUpDoor(Action):
    def __init__(self):
        Action.__init__(self, "blow_up_door")    # do basic initialization for every action
        self.isOpen = False
    
    # this method gets called when action executed.  can be overridden in subclass
    def do_action(self,game,room,request):
        self.isOpen = True
        room.open_cell(True)
        set_cutscene("MacGyver uses the can of Diet Tab and the safety pin to blow up the cell door.")
        return
    
    # should this action be available to player?
    def is_enabled(self):
        game = get_game()
        return (game.get_player().has_item('clothespin') and not self.isOpen)
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Blow Up Cell Door"
    
    # if omitted in your action we return "post"
    def get_method(self):
        return "get"